namespace LSW.Wcf.App.Report
{
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms;
    using Telerik.Reporting;
    using Telerik.Reporting.Drawing;

    /// <summary>
    /// Summary description for Employees.
    /// </summary>
    public partial class TimeSheets : Telerik.Reporting.Report
    {
        public TimeSheets()
        {
            //
            // Required for telerik Reporting designer support
            //
            InitializeComponent();
            
            foreach (var item in this.detail.Items)
            {
                
                if (item is Telerik.Reporting.TextBox)
                {
                    
                    if ((item as Telerik.Reporting.TextBox).Value.Contains("=Fields.N"))
                    {
                        string dateString = (item as Telerik.Reporting.TextBox).Value.Replace("=Fields.N", "");

                        Telerik.Reporting.Drawing.FormattingRule formattingRule1 = new Telerik.Reporting.Drawing.FormattingRule();
                        Telerik.Reporting.Drawing.FormattingRule formattingRule2 = new Telerik.Reporting.Drawing.FormattingRule();
                        Telerik.Reporting.Drawing.FormattingRule formattingRule3 = new Telerik.Reporting.Drawing.FormattingRule();
                        Telerik.Reporting.Drawing.FormattingRule formattingRule4 = new Telerik.Reporting.Drawing.FormattingRule();
                        Telerik.Reporting.Drawing.FormattingRule formattingRule5 = new Telerik.Reporting.Drawing.FormattingRule();

                        formattingRule1.Filters.AddRange(new Telerik.Reporting.Data.Filter[] 
                        { 
                            new Telerik.Reporting.Data.Filter((item as Telerik.Reporting.TextBox).Value, Telerik.Reporting.Data.FilterOperator.Equal, "-1") 
                        });
                        formattingRule1.Style.BackgroundColor = System.Drawing.Color.DarkGray;
                        formattingRule1.Style.Color = System.Drawing.Color.DarkGray;

                        formattingRule2.Filters.AddRange(new Telerik.Reporting.Data.Filter[] { new Telerik.Reporting.Data.Filter((item as Telerik.Reporting.TextBox).Value, Telerik.Reporting.Data.FilterOperator.Equal, "0") });
                        formattingRule2.Style.BackgroundColor = System.Drawing.Color.DarkGreen;
                        formattingRule2.Style.Color = System.Drawing.Color.DarkGreen;


                        formattingRule3.Filters.AddRange(new Telerik.Reporting.Data.Filter[] { new Telerik.Reporting.Data.Filter("= LSW.Wcf.App.Utility.IsSunday(Fields.YYYYMM + '/" + dateString + "')", Telerik.Reporting.Data.FilterOperator.Equal, "true") });
                        formattingRule3.Style.BackgroundColor = System.Drawing.Color.Violet;

                        formattingRule4.Filters.AddRange(new Telerik.Reporting.Data.Filter[] 
                        { 
                            new Telerik.Reporting.Data.Filter("= LSW.Wcf.App.Utility.IsSunday(Fields.YYYYMM + '/" + dateString + "')", Telerik.Reporting.Data.FilterOperator.Equal, "true") ,
                            new Telerik.Reporting.Data.Filter((item as Telerik.Reporting.TextBox).Value, Telerik.Reporting.Data.FilterOperator.Equal,"0") 
                        });
                        formattingRule4.Style.BackgroundColor = System.Drawing.Color.Violet;
                        formattingRule4.Style.Color = System.Drawing.Color.Violet;


                        formattingRule5.Filters.AddRange(new Telerik.Reporting.Data.Filter[] 
                        { 
                            new Telerik.Reporting.Data.Filter("= LSW.Wcf.App.Utility.IsSunday(Fields.YYYYMM + '/" + dateString + "')", Telerik.Reporting.Data.FilterOperator.Equal, "true") ,
                            new Telerik.Reporting.Data.Filter((item as Telerik.Reporting.TextBox).Value, Telerik.Reporting.Data.FilterOperator.Equal,"-1") 
                        });
                        formattingRule5.Style.BackgroundColor = System.Drawing.Color.Violet;
                        formattingRule5.Style.Color = System.Drawing.Color.Violet;

                        (item as Telerik.Reporting.TextBox).ConditionalFormatting.AddRange(new Telerik.Reporting.Drawing.FormattingRule[] { formattingRule1, formattingRule2, formattingRule3, formattingRule4, formattingRule5 });
                    }
                }
            }
            //
            // TODO: Add any constructor code after InitializeComponent call
            //
        }
    }
}